export function getMonthDate(year ,month){

    let ret = [];
    if(!year&&!month){
        let today =  new  Date();
        year = today.getFullYear();
        month = today.getMonth() + 1;
    }

    let firstDay = new Date(year ,month-1, 1);
    let firstDayWeekDay = firstDay.getDay();

    if(firstDayWeekDay === 0)firstDayWeekDay = 7;

    year = firstDay.getFullYear();
    month = firstDay.getMonth() + 1;

    let lastDayofLastMonth = new Date(year,month-1,0);
    let lastDateofLastMonth = lastDayofLastMonth.getDate();
    let preMonthDayCount = firstDayWeekDay-1;


    let lastDay = new Date(year,month,0);
    let lastData = lastDay.getDate();


    for (let i = 0;i<6*7;i++){
        let date = i-preMonthDayCount;
        let showDate = date;
        let thisMonth = month;

        if(date<= 0){
            thisMonth = month-1;
            showDate = lastDateofLastMonth + date;
        }else if(date>lastData){
            thisMonth = month+1;
            showDate = showDate - lastData;
        }


        if(thisMonth === 13) thisMonth = 1;
        if(thisMonth === 0)thisMonth = 12;

        ret.push({
            date:date,
            month:thisMonth,
            showDate:showDate
        });

    }
    return {
        year:year,
        month:month,
        days:ret
    };

}


